﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace FileMonitor.Service.ProcessMonitor.Manager
{
    internal class ServiceOperationManager
    {
        public readonly static ServiceOperationManager Instance=new ServiceOperationManager();
        private static ServiceHost host;

        private ServiceOperationManager()
        {
            host = new ServiceHost(typeof(Service.MonitorProcessService));
        }

        public void StartService() 
        {
            if (host.State == CommunicationState.Created||host.State==CommunicationState.Closed)
            {
                host.Open();
            }
        }

        public void StopService()
        {
            if (host.State == CommunicationState.Opened)
            {
                host.Close();
            }
        }

        public void Dispose()
        {
            (host as IDisposable).Dispose();
        }
    }
}
